home *** CD-ROM | disk | FTP | other *** search
/ A Teacher's Guide to the Holocaust / A Teacher's Guide to the Holocaust.iso / data / people / scripts / behactions.js next >
Text File  |  1999-12-05  |  6KB  |  120 lines

  1. // Copyright 1998,1999 Macromedia, Inc. All rights reserved.
  2.  
  3. function MM_callJS(jsStr) { //v2.0
  4.   return eval(jsStr)
  5. }
  6. function MM_changeProp(objName,x,theProp,theValue) { //v3.0
  7.   var obj = MM_findObj(objName);
  8.   if (obj && (theProp.indexOf("style.")==-1 || obj.style)) eval("obj."+theProp+"='"+theValue+"'");
  9. }
  10. function MM_checkBrowser(NSvers,NSpass,NSnoPass,IEvers,IEpass,IEnoPass,OBpass,URL,altURL) { //v3.0
  11.   var newURL='', verStr=navigator.appVersion, app=navigator.appName, version = parseFloat(verStr);
  12.   if (app.indexOf('Netscape') != -1) {
  13.     if (version >= NSvers) {if (NSpass>0) newURL=(NSpass==1)?URL:altURL;}
  14.     else {if (NSnoPass>0) newURL=(NSnoPass==1)?URL:altURL;}
  15.   } else if (app.indexOf('Microsoft') != -1) {
  16.     if (version >= IEvers || verStr.indexOf(IEvers) != -1)
  17.      {if (IEpass>0) newURL=(IEpass==1)?URL:altURL;}
  18.     else {if (IEnoPass>0) newURL=(IEnoPass==1)?URL:altURL;}
  19.   } else if (OBpass>0) newURL=(OBpass==1)?URL:altURL;
  20.   if (newURL) { window.location=unescape(newURL); document.MM_returnValue=false; }
  21. }
  22. function MM_checkPlugin(plgIn, theURL, altURL, IEGoesToURL) { //v3.0
  23.   with (navigator) if ((plugins && plugins[plgIn]) || (appName.indexOf('Microsoft') != -1 && 
  24.     (IEGoesToURL? (appVersion.indexOf('Mac') == -1 && appVersion.indexOf('3.1') == -1) :
  25.     ((plgIn.indexOf("Flash")!=-1 && window.MM_flash) || (plgIn.indexOf("Director")!=-1 && window.MM_dir))))) {
  26.      if (theURL.length>2) window.location = theURL;
  27.   } else if (altURL.length>2) window.location = altURL; document.MM_returnValue = false;
  28. }
  29. function MM_controlShockwave(objStr,x,cmdName,frameNum) { //v3.0
  30.   var obj=MM_findObj(objStr);
  31.   if (!obj) obj=MM_findObj(x);
  32.   if (obj) eval('obj.'+cmdName+'('+((cmdName=='GotoFrame')?frameNum:'')+')');
  33. }
  34. function MM_controlSound(x, _sndObj, sndFile) { //v3.0
  35.   var i, method = "", sndObj = eval(_sndObj);
  36.   if (sndObj != null) {
  37.     if (navigator.appName == 'Netscape') method = "play";
  38.     else {
  39.       if (window.MM_WMP == null) {
  40.         window.MM_WMP = false;
  41.         for(i in sndObj) if (i == "ActiveMovie") {
  42.           window.MM_WMP = true; break; 
  43.       } }
  44.       if (window.MM_WMP) method = "play";
  45.       else if (sndObj.FileName) method = "run";
  46.   } }
  47.   if (method) eval(_sndObj+"."+method+"()");
  48.   else window.location = sndFile; 
  49. }
  50. function MM_displayStatusMsg(msgStr) { //v1.0
  51.   status=msgStr;
  52.   document.MM_returnValue = true;
  53. }
  54. function MM_findObj(r, d) { //v3.0  special CourseBuilder version of findObj
  55.   var p,n,i,x;  if (!d) d=document; n=r.substring(r.lastIndexOf(".")+1);
  56.   if (n.indexOf("layers[")==0) n=n.substring(8,n.length-2);
  57.   if (parent.frames.length) { if (r.indexOf(".frames[")==6) d=eval(r.substring(0,r.indexOf("]")+10));
  58.     if ((p=r.indexOf("?"))!=-1) {n=r.substring(0,p); d=parent.frames[r.substring(p+1)].document;} }
  59.   if (!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  60.   for (i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
  61. }
  62. function MM_goToURL() { //v3.0
  63.   var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  64.   for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
  65. }
  66. function MM_openBrWindow(theURL,winName,features) { //v2.0
  67.   window.open(theURL,winName,features);
  68. }
  69. function MM_popupMsg(msg) { //v1.0
  70.   alert(msg);
  71. }
  72. function MM_preloadImages() { //v3.0
  73.   var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
  74.     var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
  75.     if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
  76. }
  77. function MM_setTextOfFrame(frameRef,newHTML,preserveBg) { //v2.0
  78.   var bodyAttr="", frameObj=eval(frameRef);
  79.   if (frameObj) with (frameObj.document) { //if frame found
  80.     if (preserveBg) bodyAttr = " BGCOLOR='"+bgColor+"' TEXT='"+fgColor+"'";
  81.     write("<HTML><BODY"+bodyAttr+">"+unescape(newHTML)+"</BODY></HTML>");
  82.     close();
  83.   }
  84. }
  85. function MM_setTextOfLayer(objName,x,newText) { //v3.0
  86.   if ((obj=MM_findObj(objName))!=null) with (obj)
  87.     if (navigator.appName=='Netscape') {document.write(unescape(newText)); document.close();}
  88.     else innerHTML = unescape(newText);
  89. }
  90. function MM_setTextOfTextfield(objName,x,newText) { //v3.0
  91.   var obj = MM_findObj(objName); if (obj) obj.value = newText;
  92. }
  93. function MM_showHideLayers() { //v3.0
  94.   var i,p,v,obj,args=MM_showHideLayers.arguments;
  95.   for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
  96.     if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
  97.     obj.visibility=v; }
  98. }
  99. function MM_swapImgRestore() { //v3.0
  100.   var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
  101. }
  102. function MM_swapImage() { //v3.0
  103.   var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
  104.    if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
  105. }
  106. function MM_validateForm() { //v3.0
  107.   var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  108.   for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]); 
  109.     if (val) { nm=val.name; if ((val=val.value)!="") {
  110.       if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
  111.         if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
  112.       } else if (test!='R') { num = parseFloat(val);
  113.         if (val!=''+num) errors+='- '+nm+' must contain a number.\n';
  114.         if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
  115.           min=test.substring(8,p); max=test.substring(p+1);
  116.           if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
  117.     } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  118.   } if (errors) alert('The following error(s) occurred:\n'+errors);
  119.   document.MM_returnValue = (errors == '');
  120. }